import http from '@/utils/http'

const BASE_URL = '/testing/reportDetailUi'

export interface ReportDetailUiResp {
  id: string
  reportId: string
  executeState: string
  assertionState: string
  exceptionMsg: string
  expandTime: string
  caseId: string
  num: string
  name: string
  operationType: string
  locationType: string
  locationExpress: string
  elementWait: string
  targetLocationType: string
  targetLocationExpress: string
  targetElementWait: string
  value: string
  expectKey: string
  expectValue: string
  description: string
  isContinue: string
  isScreenshot: string
  screenshotUrl: string
  version: string
  status: string
  isDeleted: string
  createdBy: string
  updatedBy: string
  createdAt: string
  updatedAt: string
  createUserString: string
  updateUserString: string
}
export interface ReportDetailUiDetailResp {
  id: string
  reportId: string
  executeState: string
  assertionState: string
  exceptionMsg: string
  expandTime: string
  caseId: string
  num: string
  name: string
  operationType: string
  locationType: string
  locationExpress: string
  elementWait: string
  targetLocationType: string
  targetLocationExpress: string
  targetElementWait: string
  value: string
  expectKey: string
  expectValue: string
  description: string
  isContinue: string
  isScreenshot: string
  screenshotUrl: string
  version: string
  status: string
  isDeleted: string
  createdBy: string
  updatedBy: string
  createdAt: string
  updatedAt: string
  createUserString: string
  updateUserString: string
}
export interface ReportDetailUiQuery {
  version: string
  createdBy: string
  sort: Array<string>
}
export interface ReportDetailUiPageQuery extends ReportDetailUiQuery, PageQuery {}

/** @desc 查询UI测试报告列表 */
export function listReportDetailUi(query: ReportDetailUiPageQuery) {
  return http.get<PageRes<ReportDetailUiResp[]>>(`${BASE_URL}`, query)
}

/** @desc 查询UI测试报告详情 */
export function getReportDetailUi(id: string) {
  return http.get<ReportDetailUiDetailResp>(`${BASE_URL}/${id}`)
}

/** @desc 新增UI测试报告 */
export function addReportDetailUi(data: any) {
  return http.post(`${BASE_URL}`, data)
}

/** @desc 修改UI测试报告 */
export function updateReportDetailUi(data: any, id: string) {
  return http.put(`${BASE_URL}/${id}`, data)
}

/** @desc 删除UI测试报告 */
export function deleteReportDetailUi(id: string) {
  return http.del(`${BASE_URL}/${id}`)
}

/** @desc 导出UI测试报告 */
export function exportReportDetailUi(query: ReportDetailUiQuery) {
  return http.download<any>(`${BASE_URL}/export`, query)
}
